<?php
require_once 'phpmoko/lib/common.php';

require_once 'phpmoko/ui/Widget.php';

class Label extends Widget
{
	private $text;
	/**
	 *
	 * @var Widget
	 */
	private $forWidget = null;

	function __construct($text)
	{
		parent::__construct();
		$this->text = $text;
		$this->addStyleName('pmk-Label');
	}

	function setLinkedWidget($widget)
	{
		$this->forWidget = $widget;
	}

	function toString()
	{
		$str = '<label';

		$str .= ' id="' . $this->id . '"';

		if (($this->forWidget != null) && ($this->forWidget->getId() != null))
			$str .= ' for="' . $this->forWidget->getId() . '"';

		$str .= ' style="white-space: nowrap;';

		if (!$this->isVisible())
			$str .= ' display: none;';

		$str .= '"';

		if ($this->style != null)
			$str .= ' class="' . $this->style . '"';

		$str .= '>';

		$str .= $this->text;

		$str .= '</label>';

		return $str;
	}
}
?>